import Vue from 'vue'
import App from './App'
import store from './store'
import textView from './components/textView.vue';
import itemList from './components/itemList.vue';
Vue.component('textView', textView);
Vue.component('itemList', itemList);

/* 全局注册QS-inputs-split组件 */
import QSInput from './components/QS-inputs-split/elements/QS-input/index.vue';

Vue.component('QSInput',QSInput);

Vue.prototype.serverUrl = "/nbjy-api";
Vue.prototype.serverUrl2 = "/nbjy-api";
Vue.prototype.pageSize = "10";

const msg = (title, duration=1500, mask=false, icon='none')=>{
	//统一提示方便全局修改
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const loading = (statu, title = '加载中') => {
	// Loading
	if (Boolean(statu) === false) {
		uni.hideLoading();
	} else {
		uni.showLoading({
			title
		});
	}
}

const prePage = ()=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}

const prePrePage = ()=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 4];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}

Vue.config.productionTip = false
Vue.prototype.$store = store;
Vue.prototype.$api = {msg,loading, prePage, prePrePage};

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
